using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class UI组件_颜色选择 : MonoBehaviour
{
    public Button 按钮;
    public Image Image;

    public Color 默认色;

    private UnityAction<Color> 当色彩改变时;
    
    public void 初始化(UnityAction<Color> 当色彩改变时=null)
    {
        this.当色彩改变时 += 当色彩改变时;
    }

    private void 当色彩改变时_fun(Color 色彩)
    {
        Image.color = 色彩;
        默认色 = 色彩;
    }

    private void Start()
    {
        按钮.onClick.AddListener(当按钮按下);
        Image.color = 默认色;
        当色彩改变时 += 当色彩改变时_fun;
    }
    bool 已开启面板 = false;
    private void 当按钮按下()
    {
        if (!已开启面板)
        {
            已开启面板 = true;
            UI管理器.获取实例.加载面板<UI组件_色彩拾取器>("面板/颜色拾取器", UI层级.上层,(t)=>{
                t.初始化(默认色, 当色彩改变时, () => 已开启面板 = false);
            });
        }
    }
}
